10  REM
15  REM BMODEM.BAS  TUNED FOR KAYPRO  1/26/86  
20  REM THIS PROGRAM HAS BEEN TESTED AT 300 BAUD
22  REM AND WILL PROBABLY NOT WORK AT HIGHER BAUD RATES !
25  REM SEE BMODEM.DOC FOR A SHORT DESCRIPTION OF ITS 
26  REM FUNCTION.
30  REM
100 GOTO 280
110 X=(INP(STATUS) AND RMASK):RETURN
120 Y=INP(MODEM):RETURN
130 X=(INP(STATUS) AND SMASK):RETURN
140 OUT MODEM,Y:RETURN
150 GOSUB 130:IF X THEN 140 ELSE 150
160 GOSUB 110:IF X THEN 120 ELSE 160
170 GOSUB 110:IF X THEN GOSUB 120:PRINT CHR$(Y);:GOTO 170
180 Y$="":Y$=INKEY$:IF Y$=""THEN 170
190 IF Y$=T$ THEN Y$=DC3$ ELSE IF Y$=ESC$ THEN Y$=ETX$
200 IF Y$<>E$ THEN Y=ASC(Y$):GOSUB 140:GOTO 170
210 INPUT "ENTER FILE NAME TO RECEIVE? ",F$:OPEN "R",1,F$
220 FIELD 1,128 AS A$:Y=NAK:GOSUB 150:FOR I=1 TO 1E+06:PRINT I;CHR$(13);
230 C=0:GOSUB 160:IF Y=EOT THEN Y=ACK:GOSUB 150:CLOSE 1:PRINT CHR$(7):GOTO 170
240 GOSUB 160:J=Y:GOSUB 160:IF J+Y <> 255 THEN C=13
250 FOR J=1 TO 128:GOSUB 160:MID$(B$,J,1)=CHR$(Y):C=C+Y:NEXT
260 GOSUB 160:C=C AND 255:IF C<>Y THEN Y=NAK:GOSUB 150:GOTO 230
270 LSET A$=B$:PUT 1,I:Y=ACK:GOSUB 150:NEXT
272 REM
275 REM  KAYPRO VALUES   LRB
277 REM
280 MODEM=4:STATUS=6:RMASK=1:SMASK=4
290 B$=STRING$(128,0):ACK=6:NAK=21:E$=CHR$(5):WIDTH 255:EOT=4
300 ESC$=CHR$(27):ETX$=CHR$(3):DC3$=CHR$(19):T$="~":GOTO 170
310 END
STRING$(128,0):ACK=6:NAK=21:E$=CHR$(5):WIDTH 255:EOT=4
300 ESC$=CHR$(27):ETX$=CH